class BaseResponse {
  //访问成功 == 0
  int errno;

  //访问失败时候，的描述信息
  String error;

  // 透传网络数据
  var data;

  BaseResponse({this.errno, this.error, this.data});

  BaseResponse.fromJson(Map<String, dynamic> json) {
    data = json["data"];
    errno = json["errno"];
    error = json["error"];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data["data"] = this.data;
    data["errno"] = this.errno;
    data["error"] = this.error;
    return data;
  }

  /// 请求成功
  bool success() {
    return errno == 0;
  }

  bool hasData(){
    return success() && data != null;
  }

  @override
  String toString() {
    return 'BaseResponse{errno: $errno, error: $error, data: $data}';
  }
}
